//index.js
// src: "https://api.bshlsqs.com/statics/xiaochengxu"
//获取应用实例



const app = getApp()
Page({
  data: {
    src: "",
    uid: "",
    invite_code: "",
    payType: "",
    latitude: "",
    longitude: "",
    city: "",
  },

  //事件处理函数   
  onLoad: function(options) {
    console.log(options)
    let that = this;
    var basrUrl = ""
    var uid = ""
    var invite_code = ""

    // uid 
    wx.getStorage({
      key: 'uid',
      success: function(res) {
        uid = res.data
        // invite_code
        wx.getStorage({
          key: 'invite_code',
          success: function(res) {
            invite_code = res.data
            // 基本路径
            basrUrl = `https://api.bshlsqs.com/statics/xiaochengxu?uid=${uid}&invite_code=${invite_code}`

            // 支付成功回调
            if (options.payType) {
              var payType = options.payType;
              var result = `${basrUrl}?payType=${payType}`
            }

            // 传递城市参数
            if (options.city) {
              var city = options.city;
              var result = `${basrUrl}?city=${city}`
            }

            // 邀请用户参数
            if (options.inType) {
              var inType = options.inType
              var result = `${basrUrl}?inType=${inType}`
            }

            // 传递使用水票参数
            if (options.isuseTicket) {
              var isuseTicket = options.isuseTicket;
              var useTicketNumber = options.useTicketNumber;
              var productId = options.productId;
              var result = `${basrUrl}?isuseTicket=${isuseTicket}&useTicketNumber=${useTicketNumber}&productId=${productId}`
            }

            // 申请入股
            if (options.applyType) {
              var applyType = options.applyType;
              var result = `${basrUrl}?applyType=${applyType}`

            }


            console.log(`${result}`)

            // 最后链接
            that.setData({
              src: `${result}`
            })


          },
        })
      },
    })
  },

})